# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.spark_submit import SparkSubmitOperator
from jms.dim.dim_network_whole_massage import jms_dim__dim_network_whole_massage
from jms.dwd.tab.dwd_barscan_sitesend_dt import jms_dwd__dwd_barscan_sitesend_dt
from jms.dwd.tab.dwd_barscan_sitearrival_dt import jms_dwd__dwd_barscan_sitearrival_dt
from jms.dwd.tab.dwd_tab_barscan_taking_base_dt import jms_dwd__dwd_tab_barscan_taking_base_dt
from jms.dwd.tab.dwd_tab_barscan_warehousing_base_dt import jms_dwd__dwd_tab_barscan_warehousing_base_dt
from jms.dwd.tab.dwd_tab_barscan_deliver_base_dt import jms_dwd__dwd_tab_barscan_deliver_base_dt
from jms.dwd.oms.dwd_yl_oms_oms_waybill_incre_dt import jms_dwd__dwd_yl_oms_oms_waybill_incre_dt
from jms.dwd.tab.dwd_tab_barscan_difficult_base_dt import jms_dwd__dwd_tab_barscan_difficult_base_dt
from jms.time_sensor.time_after_05_00 import time_after_05_00


# 揽收漏扫明细
dm__dm_network_repeat_scan_detail = SparkSubmitOperator(
    task_id='dm__dm_network_repeat_scan_detail',
    pool_slots=11,
    task_concurrency=1,  # 如果任务不支持并发，则将 task_concurrency 设为 1
    name='dm__dm_network_repeat_scan_detail_{{ execution_date | date_add(1) | cst_ds }}',
    driver_memory='12G',
    executor_memory='12G',
    executor_cores=8,
    num_executors=24,
    email=['guoruiling@jtexpress.com','yl_bigdata@yl-scm.com'],
    conf={'spark.executor.memoryOverhead': 4096,
          'spark.core.connection.ack.wait.timeout': 5000,
          'spark.default.parallelism': 600,
          'spark.locality.wait': 60,
          'spark.driver.maxResultSize': 20,
          },
    java_class='com.yunlu.bigdata.jobs.export.ExportNetworkRepeatScanData',
    application='hdfs:///scheduler/jms/spark/zyt/network_repeat_scan/NetworkRepeatScanData.jar',
    application_args=['{{ execution_date | cst_ds }}'],
    execution_timeout=timedelta(hours=3),
)

dm__dm_network_repeat_scan_detail << [
    jms_dwd__dwd_barscan_sitesend_dt,
    jms_dwd__dwd_barscan_sitearrival_dt,
    jms_dwd__dwd_tab_barscan_taking_base_dt,
    jms_dwd__dwd_tab_barscan_warehousing_base_dt,
    jms_dwd__dwd_tab_barscan_deliver_base_dt,
    jms_dwd__dwd_yl_oms_oms_waybill_incre_dt,
    jms_dwd__dwd_tab_barscan_difficult_base_dt,
    jms_dim__dim_network_whole_massage,
    time_after_05_00
]